<?php
namespace Home\Model;
use Think\Model;

class FeedbackModel extends Model {

    protected $_validate = array (
		array('mobile', 'require', '电话不能为空'),
		array('mobile', 'checkmobile', '手机号格式输入有误', 0, 'callback', 1),
		array('name','require','姓名不能为空', 1),
    	array('email','require','邮箱不能为空', 1),
    	array('content','require','问题内容不能为空', 1),		
    );	

    protected $_auto = array (
		array('createTime','time',Model::MODEL_INSERT,'function'),		
		array('updateTime','time',Model::MODEL_BOTH,'function'),
		array('open','0',Model::MODEL_BOTH,'string'),
		array('status','0',Model::MODEL_BOTH,'string'),
		array('path','',Model::MODEL_BOTH,'string'),
		array('ip','get_client_ip',Model::MODEL_BOTH,'function'),
	);
	
	protected function checkmobile($mobile){
		$mobilepreg = '/^1[3|4|5|7|8][0-9]{9}$/';
		if (!preg_match($mobilepreg, $mobile)) {
			return false;
		}else {
			return true;
		}
	}

	protected function checkemail($email){
		$emailpreg = '/^(?:\\w+\\.?)*\\w+@(?:\\w+\\.)+\\w+$/';
		if (!preg_match($emailpreg, $email)) {
			return false;
		}else{
			return true;
		}
	}
}
?>